<template>
  <div id="ts">
    <div id="prompt"></div>
    <div id="key"></div>
    <div id="session">
      <span>您还没有登录，{{item}}秒后跳转登录页面</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "GlobalPrompt",
  data() {
    return{
      item: 3
    }
  },
  created(){
    let item = setInterval(() => {
      this.item--
      
      if(this.item == 0) return clearInterval(item)
    },1000)
  }
};
</script>

<style>
#session {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
}
#session span {
  display: block;
  text-align: center;
  background: rgba(0, 0, 0, 0.8);
  margin: 5px auto;
  padding: 20px;
  width: 210px;
  height: 60px;
  line-height: 60px;
  user-select: none;
  color: white;
  font-size: 13px;
  animation: 0.3s session ease;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
}
@keyframes session {
  0% {
    opacity: 0;
    transform: translate(0, -100%);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0);
  }
}
#ts {
  position: fixed;
  top: 50px;
  left: 50%;
  z-index: 10;
}
#prompt,
#key {
  transform: translateX(-50%);
}
#prompt {
  display: none;
  padding: 7px 20px;
  text-align: center;
  background-color: rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 5px 2px rgba(124, 0, 118, 0.1);
  font-size: 12px;
  border-radius: 8px;
  color: white;
  user-select: none;
  animation: 0.5s swing ease;
  font-weight: 100;
}
#key {
  display: none;
  padding: 7px 20px;
  text-align: center;
  background-color: rgba(89, 212, 77);
  box-shadow: 0 0 5px 2px rgba(124, 0, 118, 0.1);
  z-index: 10;
  font-size: 12px;
  border-radius: 8px;
  color: white;
  user-select: none;
  font-weight: 500;
}
@keyframes swing {
  0% {
    transform: translateX(-50%);
  }
  30% {
    transform: translateX(-80%);
  }
  50% {
    transform: translateX(-20%);
  }
  70% {
    transform: translateX(-80%);
  }
  100% {
    transform: translateX(-50%);
  }
}
</style>
